package edu.chl.da.ejb.core;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * Respresent a destination
 * @author Jakob
 */
@Entity
@Table(name = "DESTINATION")
@NamedQueries({
    @NamedQuery(name = "Destination.findAll", query = "SELECT d FROM Destination d"),
    @NamedQuery(name = "Destination.findByName", query = "SELECT d FROM Destination d WHERE d.name = :name"),
    @NamedQuery(name = "Destination.findByGeox", query = "SELECT d FROM Destination d WHERE d.geox = :geox"),
    @NamedQuery(name = "Destination.findByGeoy", query = "SELECT d FROM Destination d WHERE d.geoy = :geoy"),
    @NamedQuery(name = "Destination.findByImage", query = "SELECT d FROM Destination d WHERE d.image = :image")})
public class Destination implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "NAME")
    private String name;
    @Column(name = "GEOX")
    private Double geox;
    @Column(name = "GEOY")
    private Double geoy;
    @Column(name = "IMAGE")
    private String image;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "destination1")
    private List<Airport> airportList;

    public Destination() {
    }

    public Destination(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Double getGeox() {
        return geox;
    }

    public void setGeox(Double geox) {
        this.geox = geox;
    }

    public Double getGeoy() {
        return geoy;
    }

    public void setGeoy(Double geoy) {
        this.geoy = geoy;
    }

    public String getImage() {
        return image;
    }

    public void setImage(String image) {
        this.image = image;
    }

    public List<Airport> getAirportList() {
        return airportList;
    }

    public void setAirportList(List<Airport> airportList) {
        this.airportList = airportList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (name != null ? name.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Destination)) {
            return false;
        }
        Destination other = (Destination) object;
        if ((this.name == null && other.name != null) || (this.name != null && !this.name.equals(other.name))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "edu.chl.da.ejb.core.Destination[name=" + name + "]";
    }

}
